// Dom7
var $$ = Dom7;
var timeout = 30 * 1000;
var inteval = 30 * 1000;
var inner = false;
var URL_HEADER = (inner ? "../../index.php/Home/TemHumiApp/" : "http://121.42.24.64/index.php/Home/TemHumiApp/");

// Framework7 App main instance
var app = new Framework7({
  root: '#app', // App root element
  id: 'io.framework7.testapp', // App bundle ID
  name: 'PowerHub System', // App name
  theme: 'md', // Automatic theme detection
  // App root data
  data: function () {
    return {
      user: {
        firstName: 'John',
        lastName: 'Doe',
      },
      // Demo products for Catalog section
      products: [{
          id: '1',
          title: 'Apple iPhone 8',
          description: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nisi tempora similique reiciendis, error nesciunt vero, blanditiis pariatur dolor, minima sed sapiente rerum, dolorem corrupti hic modi praesentium unde saepe perspiciatis.'
        },
        {
          id: '2',
          title: 'Apple iPhone 8 Plus',
          description: 'Velit odit autem modi saepe ratione totam minus, aperiam, labore quia provident temporibus quasi est ut aliquid blanditiis beatae suscipit odio vel! Nostrum porro sunt sint eveniet maiores, dolorem itaque!'
        },
        {
          id: '3',
          title: 'Apple iPhone X',
          description: 'Expedita sequi perferendis quod illum pariatur aliquam, alias laboriosam! Vero blanditiis placeat, mollitia necessitatibus reprehenderit. Labore dolores amet quos, accusamus earum asperiores officiis assumenda optio architecto quia neque, quae eum.'
        },
      ],
      person: {
        userid: 'xpx',
        companyname: '创思捷电力',
        email: '',
        roles: '管理员'
      },
      fLastData: []
    };
  },

  //绑定事件
  on: {
    init: function () {
      //console.log('App initialized');
    },
    pageInit: function (page) {
      //console.log('pageInit');
      //console.log(page);
    },
    pageAfterIn: function (event, page) {
      // do something after page gets into the view
      //console.log('pageAfterIn');
      //console.log(page);
    }
  },
  // App root methods
  methods: {
    helloWorld: function () {
      app.dialog.alert('Hello World!');
    }
  },
  // App routes
  routes: routes,
});

// Init/Create views
var homeView = app.views.create('#view-history', {
  url: '/'
});
var historyView = app.views.create('#view-history', {
  url: '/history/'
});
var realtimeView = app.views.create('#view-realtime', {
  url: '/realtime/'
});
var queryView = app.views.create('#view-query', {
  url: '/query/'
});
var personView = app.views.create('#view-person', {
  url: '/person/'
});


// Login Screen Demo
$$('#my-login-screen .login-button').on('click', function () {
  var username = $$('#my-login-screen [name="username"]').val();
  var password = $$('#my-login-screen [name="password"]').val();

  // Close login screen
  app.loginScreen.close('#my-login-screen');

  // Alert username and password
  app.dialog.alert('Username: ' + username + '<br>Password: ' + password);
});